# frozen_string_literal: true

module RuleEntitiesHelper
  def table_generator(headers, content)
    return if content.blank?

    content_tag(:table, class: 'generic-table') do
      content_tag(:thead) do
        content_tag(:tr) do
          headers.each do |header|
            content_tag(:td, header)
          end
        end
      end

      content_tag(:tbody) do
        content.each do |row_content|
          content_tag(:tr) do
            row_content.each do |value|
              content_tag(:td, value)
            end
          end
        end
      end
    end
  end
end
